package com.yb.guigu.pick.activity;

import com.yb.guigu.pick.activity.listener.redis.DemoRedisStreamListener;
import com.yb.guigu.pick.core.bean.GuiguResult;
import com.yb.guigu.pick.web.annotation.EnableGuiguWebResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ErrorHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.Duration;
import java.util.HashMap;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/7/10 16:08
 * FileName: ActivityServiceApplication
 * Description:
 */


@SpringBootApplication
@EnableGuiguWebResource
@RestController
@Slf4j
public class ActivityServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(ActivityServiceApplication.class,args);
    }


    @Autowired
    StringRedisTemplate stringRedisTemplate;
    @GetMapping("/send")
    public GuiguResult send(){
        HashMap<String, String> content = new HashMap<>();
        content.put("name","zz");

        stringRedisTemplate.opsForStream().add(MapRecord.create("stream:key",content));

        return GuiguResult.success();
    }
}
